package com.xieyong.mywebsite.model.entity;

import com.xieyong.mywebsite.anno.State;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.groups.Default;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.URL;

@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Article extends BaseEntity{
    @NotNull(groups = {Update.class})
    private Integer id;
    @NotEmpty
    @Pattern(regexp = "^\\S{1,20}$")
    private String title;
    @NotEmpty
    private String content;
    @URL
    private String coverImg;
    @NotEmpty
//    自定义校验注解
    @State
    private String state;
    @NotNull
    private Integer categoryId;

//    不存储在数据库中
    private String categoryName;
    private String userName;
    private String nickName;

    public interface Add extends Default {}
    public interface Update extends Default {}
}
